/**
 * Class for storing the computation step separately for step count, operand, operator and the answer.
 * Dependent for the step can be set also if exist.
 * @author Color Lee
 *
 */
public class Step {
	
	private int stepNumber;
	private int operand1;
	private int operand2;
	private char operator;
	private int result;
	private Dependent dependent;
	
	/**
	 * Constructor for one Step representative
	 * @param stepNumber the step number of this step
	 * @param operand1 the first operand of this step 
	 * @param operand2 the second operand of this step
	 * @param operator the operator of this step
	 * @param result the result of this step
	 * @param dependent the dependent of this step
	 */
	public Step(int stepNumber, int operand1, int operand2, char operator, int result, Dependent dependent){
		setStepNumber(stepNumber);
		setOperand1(operand1);
		setOperand2(operand2);
		setOperator(operator);
		setResult(result);
		setDependent(dependent);
	}
	
	/**
	 * Function for setting the step number
	 * @param stepNumber the step number of this step
	 */
	public void setStepNumber(int stepNumber){ this.stepNumber = stepNumber; }
	
	/**
	 * Function for returning the step number
	 * @return the step number of this step
	 */
	public int getStepNumber(){ return stepNumber; }
	
	/**
	 * Function for setting the first operand
	 * @param operand1 the first operand of this step
	 */
	public void setOperand1(int operand1){ this.operand1 = operand1; }
	
	/**
	 * Function for returning the first operand
	 * @return the first operand of this step
	 */
	public int getOperand1(){ return operand1; }
	
	/**
	 * Function for setting the second operand
	 * @param operand2 the second operand of this step
	 */
	public void setOperand2(int operand2){ this.operand2 = operand2; }
	
	/**
	 * Function for returning the second operand
	 * @return the second operand of this step
	 */
	public int getOperand2(){ return operand2; }
	
	/**
	 * Function for setting the operator
	 * @param operator the operator of this step
	 */
	public void setOperator(char operator){ this.operator = operator; }
	
	/**
	 * Function for return the operator
	 * @return the operator of this step
	 */
	public char getOperator(){ return operator; }
	
	/**
	 * Function for setting the result
	 * @param result the result of this step
	 */
	public void setResult(int result){ this.result = result; }
	
	/**
	 * Function for returning the result
	 * @return the result of this step
	 */
	public int getResult(){ return result; }
	
	/**
	 * Function for setting the dependent
	 * @param dependent the dependent of this step
	 */
	public void setDependent(Dependent dependent){ this.dependent = dependent; }
	
	/**
	 * Function for getting the dependent
	 * @return the dependent of this step
	 */
	public Dependent getDependent(){ return dependent; }	
	
	/**
	 * Function for getting the short form statement of this step without step number and dependent
	 * @return the short form statement of this step
	 */
	public String toStringShortForm(){
		return getOperand1() + Character.toString(getOperator()) + getOperand2() + "=" + getResult();
	}
	
	/**
	 * Function for getting the full statement of this step with step number and dependent
	 * @return the full statement of this step
	 */
	public String toString(){
		return "Step " + getStepNumber() + ". " + getOperand1() + " " + getOperator() + " " + getOperand2() + " = " + getResult()
				+ (getDependent() == null ? "" : getDependent().toString());
	}
}
